package com.hxj.springboot01.controller;
import com.hxj.springboot01.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.connection.RedisConnection;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class RedisTestController {

    @Autowired
    //如果重写了原生方法，要使用此注解
    @Qualifier("redisTemplate")
    private RedisTemplate redisTemplate;
    @Autowired
    private RedisUtil redisUtil;


    @GetMapping("/getRedisConnect")
    public String getRedisConnect(){
        RedisConnection connection = redisTemplate.getConnectionFactory().getConnection();
        return connection.toString();
    }
    @GetMapping("/setRedisValue")
    public String setRedisValue(){
         redisTemplate.opsForValue().set("ssss","ooo");
        return "success";
    }
    @GetMapping("/testUtil")
    public boolean testUtil(){
        boolean set = redisUtil.set("xiaiogou", "xiaomao");
        return set;
    }

}
